var projectName = '课堂教学管理系统设计与实现';
/**
 * 轮播图配置
 */
var swiper = {
    // 设定轮播容器宽度，支持像素和百分比
    width: '100%',
    height: '400px',
    // hover（悬停显示）
    // always（始终显示）
    // none（始终不显示）
    arrow: 'none',
    // default（左右切换）
    // updown（上下切换）
    // fade（渐隐渐显切换）
    anim: 'default',
    // 自动切换的时间间隔
    // 默认3000
    interval: 2000,
    // 指示器位置
    // inside（容器内部）
    // outside（容器外部）
    // none（不显示）
    indicator: 'outside'
}

/**
 * 个人中心菜单
 */
var centerMenu = [{
    name: '个人中心',
    url: '../' + localStorage.getItem('userTable') + '/center.jsp'
},
    {
        name: '考试记录',
        url: '../examrecord/list.jsp'
    },
    // {
    //     name: '错题本',
    //     url: '../examrecord/wrong.jsp'
    // },
    {
        name: '我的收藏',
        url: '../storeup/list.jsp'
    }
]


var indexNav = [
    {
        name: '教学视频',
        url: './pages/jiaoxueshipin/list.jsp'
    },

    {
        name: '试卷',
        url: './pages/exampaper/list.jsp'
    },
    {
        name: '教学资讯',
        url: './pages/news/list.jsp'
    },
    {
        name: '留言板',
        url: './pages/messages/list.jsp'
    }
]

var adminurl = "http://localhost:8080/jspmk28g8/index.jsp";

var cartFlag = false

var chatFlag = false


var menu = [{
    "backMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-goodsnew",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "学生",
            "menuJump": "列表",
            "tableName": "xuesheng"
        }], "menu": "学生管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-rank",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "教师",
            "menuJump": "列表",
            "tableName": "jiaoshi"
        }], "menu": "教师管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-copy",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "教学视频",
            "menuJump": "列表",
            "tableName": "jiaoxueshipin"
        }], "menu": "教学视频管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-form",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "分类",
            "menuJump": "列表",
            "tableName": "fenlei"
        }], "menu": "分类管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-present",
            "buttons": ["新增", "查看", "修改", "删除", "报表"],
            "menu": "任务管理",
            "menuJump": "列表",
            "tableName": "renwuguanli"
        }], "menu": "任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-wenzi",
            "buttons": ["新增", "查看", "修改", "删除", "报表"],
            "menu": "完成任务",
            "menuJump": "列表",
            "tableName": "wanchengrenwu"
        }], "menu": "完成任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-taxi",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "签到模块",
            "menuJump": "列表",
            "tableName": "qiandaomokuai"
        }], "menu": "签到模块管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-list",
            "buttons": ["新增", "查看", "修改", "删除", "报表"],
            "menu": "学生签到",
            "menuJump": "列表",
            "tableName": "xueshengqiandao"
        }], "menu": "学生签到管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-flashlightopen",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "试卷管理",
            "tableName": "exampaper"
        }], "menu": "试卷管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-keyboard",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "试题管理",
            "tableName": "examquestion"
        }], "menu": "试题管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-flashlightopen",
            "buttons": ["查看", "修改", "回复", "删除"],
            "menu": "留言板管理",
            "tableName": "messages"
        }], "menu": "留言板管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-news",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "教学资讯",
            "tableName": "news"
        }, {
            "appFrontIcon": "cuIcon-qrcode",
            "buttons": ["新增", "查看", "修改", "删除"],
            "menu": "轮播图管理",
            "tableName": "config"
        }], "menu": "系统管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-link",
            "buttons": ["查看"],
            "menu": "考试记录",
            "tableName": "examrecord"
        }, {
            "appFrontIcon": "cuIcon-time",
            "buttons": ["查看"],
            "menu": "错题本",
            "tableName": "examfailrecord"
        }, {"appFrontIcon": "cuIcon-present", "buttons": ["查看"], "menu": "试卷列表", "tableName": "exampaperlist"}],
        "menu": "考试管理"
    }],
    "frontMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-skin",
            "buttons": ["查看", "查看评论"],
            "menu": "教学视频列表",
            "menuJump": "列表",
            "tableName": "jiaoxueshipin"
        }], "menu": "教学视频模块"
    }],
    "hasBackLogin": "是",
    "hasBackRegister": "否",
    "hasFrontLogin": "否",
    "hasFrontRegister": "否",
    "roleName": "管理员",
    "tableName": "users"
}, {
    "backMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-present",
            "buttons": ["查看", "完成任务"],
            "menu": "任务管理",
            "menuJump": "列表",
            "tableName": "renwuguanli"
        }], "menu": "任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-wenzi",
            "buttons": ["查看"],
            "menu": "完成任务",
            "menuJump": "列表",
            "tableName": "wanchengrenwu"
        }], "menu": "完成任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-taxi",
            "buttons": ["查看", "签到"],
            "menu": "签到模块",
            "menuJump": "列表",
            "tableName": "qiandaomokuai"
        }], "menu": "签到模块管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-list",
            "buttons": ["查看"],
            "menu": "学生签到",
            "menuJump": "列表",
            "tableName": "xueshengqiandao"
        }], "menu": "学生签到管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-flashlightopen",
            "buttons": ["查看", "删除"],
            "menu": "留言板管理",
            "tableName": "messages"
        }], "menu": "留言板管理"
    }],
    "frontMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-skin",
            "buttons": ["查看", "查看评论"],
            "menu": "教学视频列表",
            "menuJump": "列表",
            "tableName": "jiaoxueshipin"
        }], "menu": "教学视频模块"
    }],
    "hasBackLogin": "否",
    "hasBackRegister": "否",
    "hasFrontLogin": "是",
    "hasFrontRegister": "是",
    "roleName": "学生",
    "tableName": "xuesheng"
}, {
    "backMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-goodsnew",
            "buttons": ["发布任务", "查看"],
            "menu": "学生",
            "menuJump": "列表",
            "tableName": "xuesheng"
        }], "menu": "学生管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-copy",
            "buttons": ["新增", "查看", "修改", "删除", "查看评论"],
            "menu": "教学视频",
            "menuJump": "列表",
            "tableName": "jiaoxueshipin"
        }], "menu": "教学视频管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-present",
            "buttons": ["查看", "删除", "报表"],
            "menu": "任务管理",
            "menuJump": "列表",
            "tableName": "renwuguanli"
        }], "menu": "任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-wenzi",
            "buttons": ["查看", "删除", "报表", "审核"],
            "menu": "完成任务",
            "menuJump": "列表",
            "tableName": "wanchengrenwu"
        }], "menu": "完成任务管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-taxi",
            "buttons": ["查看", "删除", "新增", "修改"],
            "menu": "签到模块",
            "menuJump": "列表",
            "tableName": "qiandaomokuai"
        }], "menu": "签到模块管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-list",
            "buttons": ["查看", "删除", "报表"],
            "menu": "学生签到",
            "menuJump": "列表",
            "tableName": "xueshengqiandao"
        }], "menu": "学生签到管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-flashlightopen",
            "buttons": ["查看", "回复", "删除"],
            "menu": "留言板管理",
            "tableName": "messages"
        }], "menu": "留言板管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-flashlightopen",
            "buttons": ["新增", "查看", "修改"],
            "menu": "试卷管理",
            "tableName": "exampaper"
        }], "menu": "试卷管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-keyboard",
            "buttons": ["新增", "查看", "修改"],
            "menu": "试题管理",
            "tableName": "examquestion"
        }], "menu": "试题管理"
    }, {
        "child": [{
            "appFrontIcon": "cuIcon-time",
            "buttons": ["查看"],
            "menu": "错题本",
            "tableName": "examfailrecord"
        }, {
            "appFrontIcon": "cuIcon-present",
            "buttons": ["查看"],
            "menu": "试卷列表",
            "tableName": "exampaperlist"
        }, {"appFrontIcon": "cuIcon-link", "buttons": ["查看"], "menu": "考试记录", "tableName": "examrecord"}],
        "menu": "考试管理"
    }],
    "frontMenu": [{
        "child": [{
            "appFrontIcon": "cuIcon-skin",
            "buttons": ["查看", "查看评论"],
            "menu": "教学视频列表",
            "menuJump": "列表",
            "tableName": "jiaoxueshipin"
        }], "menu": "教学视频模块"
    }],
    "hasBackLogin": "是",
    "hasBackRegister": "否",
    "hasFrontLogin": "否",
    "hasFrontRegister": "否",
    "roleName": "教师",
    "tableName": "jiaoshi"
}]


var isAuth = function (tableName, key) {
    let role = localStorage.getItem("userTable");
    let menus = menu;
    for (let i = 0; i < menus.length; i++) {
        if (menus[i].tableName == role) {
            for (let j = 0; j < menus[i].backMenu.length; j++) {
                for (let k = 0; k < menus[i].backMenu[j].child.length; k++) {
                    if (tableName == menus[i].backMenu[j].child[k].tableName) {
                        let buttons = menus[i].backMenu[j].child[k].buttons.join(',');
                        return buttons.indexOf(key) !== -1 || false
                    }
                }
            }
        }
    }
    return false;
}

var isFrontAuth = function (tableName, key) {
    let role = localStorage.getItem("userTable");
    let menus = menu;
    for (let i = 0; i < menus.length; i++) {
        if (menus[i].tableName == role) {
            for (let j = 0; j < menus[i].frontMenu.length; j++) {
                for (let k = 0; k < menus[i].frontMenu[j].child.length; k++) {
                    if (tableName == menus[i].frontMenu[j].child[k].tableName) {
                        let buttons = menus[i].frontMenu[j].child[k].buttons.join(',');
                        return buttons.indexOf(key) !== -1 || false
                    }
                }
            }
        }
    }
    return false;
}